function getRootPath_web() {
            //获取当前网址，如： http://localhost:8083/uimcardprj/share/meun.jsp
            var curWwwPath = window.document.location.href;
            //获取主机地址之后的目录，如： uimcardprj/share/meun.jsp
            var pathName = window.document.location.pathname;
            var pos = curWwwPath.indexOf(pathName);
            //获取主机地址，如： http://localhost:8083
            var localhostPaht = curWwwPath.substring(0, pos);
            //获取带"/"的项目名，如：/uimcardprj
            var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
            //return (localhostPaht + projectName);
            return (localhostPaht);
        }

basePath = getRootPath_web();


var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
//ajax全局
axios.defaults.baseURL = basePath;

//预先过滤所有request
axios.interceptors.request.use(function (config) {
  config.headers["X-Requested-With"] = "XMLHttpRequest";
  return config;
}, function (error) {
  return Promise.reject(error);
});

//预先过滤所有response
axios.interceptors.response.use(function (response) {
  var data = response.data;
  if ((typeof data === "undefined" ? "undefined" : _typeof(data)) !== "object") {
	  layer.msg("JSON数据解析失败",{time:1000});
	  return;
  }

  if (response.data.code == "-3") {
	  forwardLogin();
	  return;
  }
  return data;
}, function (error) {
	layer.msg("网络请求失败",{time:1000});
	return Promise.reject(error);
});






$(function(){  
    // 设置jQuery Ajax全局的参数  
    $.ajaxSetup({  
        type: "POST",  
        error: function(jqXHR, textStatus, errorThrown){  
            switch (jqXHR.status){
                case(500):  
                    alert("服务器系统内部错误");  
                    break;  
                case(401):  
                    alert("未登录");  
                    break;  
                case(403):  
                    alert("无权限执行此操作");  
                    break;  
                case(408):  
                    alert("请求超时");  
                    break;  
                default:  
                    alert("未知错误");  
            }  
        },   
        success: function(data){  
            alert("操作成功");  
        }  
    });  
});

function isEmpty(str){
	if(!str){
		return "";
	}else{
		return str;
	}
}

function getQueryString(name) { 
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); 
	var r = window.location.search.substr(1).match(reg); 
	if (r != null) return unescape(r[2]); return null; 
} 

$(function(){
	$(".menu_dropdown ul li a").on("click",function(){
		//alert(seesionIsExist("admin"));
		if(seesionIsExist("admin") == "" || seesionIsExist("admin") == null) {
			forwardLogin();
			return false;
		}
	})
});



var forwardLogin = function(){
	layer.msg("管理员登录超时，请重新登录",{time:2000});
		 setTimeout(function(){
			 window.parent.parent.location.href=basePath+"/";	 
  	 },3000);
}

function removeIframe(){
	var index = parent.layer.getFrameIndex(window.name);
	 parent.layer.close(index);
}

/**
 * 获取session
 */
var seesionIsExist = function (sessionName){
	var session="";
	$.ajax({
		type:"post",
		//url:basePath+"/dic/validateValue",
		url:basePath+"/getSessionByName",
		data:{"sName":sessionName},
		async:false,
		success:function(resp){
			 session = resp.data
		}
	});
	return session;
}



/**
 * 获取显示值
 * @param tableName
 * @param fieldName
 * @param val
 * @returns {String}
 */
function getDicVal(dicCode,dicValue){
	$.ajaxSetup({   
        async : false  
    });
	var value = ""
	$.post(basePath+"/dic/getDicValue",{"dicCode":dicCode,"dicValue":dicValue},function(resp){
		value =  resp.data.value;
	});
	return value;
}

/**
 * 获取字典集
 * @param dicCode
 */
function getDicList(dicCode){
	var data = "";
	$.ajax({
		type:"post",
		//url:basePath+"/dic/validateValue",
		url:basePath+"/dic/getDicListByCode",
		data:{"dicCode":dicCode},
		async:false,
		success:function(resp){
			 if(resp.code == "0"){
				 data = resp.data;
		        }
		}
	});
	
	return data;
}

/**
 * 获取字典集
 * @param dicCode
 */
function removeWindow(){
	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
	parent.layer.close(index); //再执行关闭   
}


/**
 * 防止用户直接关闭窗口

$(window).bind('beforeunload',function(){  

	  $.ajax({  

	    url:basePath+"/admin/adminLoginOut?outType=wind",  

	    type:"post",  

	    success:function(){  

	        //alert("您已退出登录");  

	    }  

	});  

});   */
